#include "listltembox.h"
#include "ui_listltembox.h"
#include<QDebug>

ListltemBox::ListltemBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ListltemBox),
  isLike(false)
{
    ui->setupUi(this);
    connect(ui->likeBtn, &QPushButton::clicked, this,&ListltemBox::onLikeBtnClicked);
}

ListltemBox::~ListltemBox()
{
    delete ui;
}
void  ListltemBox::enterEvent(QEvent *event)
{
    (void)event;
    setStyleSheet("background-color:#EFEFEF");
}

void  ListltemBox::leaveEvent(QEvent *event)

{
    (void)event;
    setStyleSheet("");

}

void ListltemBox::onLikeBtnClicked()
{
   isLike=!isLike;
   setLikeIcon(isLike);
   emit setIsLike(isLike);
   qDebug()<<"emit setIsLike signal";
}


void ListltemBox::setMusicName(const QString& name)
{
ui->musicNameLabel->setText(name);
}
void ListltemBox::setSinger(const QString& singer)
{
ui->musicSingerLabel->setText(singer);
}
void ListltemBox::setAlbumName(const QString& albumName)
{
    ui->albumNameLabel->setText(albumName);
}

void ListltemBox::setLikeIcon(bool islike)
{
    isLike = islike;
    if(isLike)
    {
    ui->likeBtn->setIcon(QIcon(":/images/like_2.png"));
    }
    else
    {
    ui->likeBtn->setIcon(QIcon(":/images/like_3.png"));
    }

}


